#include "widget.h"
#include "ui_widget.h"
#include<fstream>
#include<QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    //读取文件内容，每一行作为combobox的一个选项
    std::ifstream file("C:/Users/xuan/Desktop/config.txt");
    if(!file.is_open())
    {
        qDebug() << "文件打开失败";
        return;
    }
    //按行读取 getline
    std::string line;
    while(std::getline(file,line)){
        ui->comboBox->addItem(QString::fromStdString(line));
    }
    file.close();
}

Widget::~Widget()
{
    delete ui;
}

